<%-- 
    Document   : ps
    Created on : 2014/8/20, 上午 11:21:01
    Author     : gjun
--%>

<%@page import="java.sql.Statement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
    
//import時 注意要java.sql.的開頭
    Class.forName("com.mysql.jdbc.Driver");//載入資料庫驅動程式
    Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/javadb","root","root") ;
          //  .getConnection(Services頁-內的database的connection內的URL,帳號,密碼)
    //Statement st= con.createStatement();
    
    String sql="insert into person (username,tel,birthday)values(?,?,?)";
    java.sql.PreparedStatement ps=con.prepareStatement(sql);
    ps.setString(1,"Jom's cat");
    ps.setString(2,"08-456974");
    ps.setString(3,"2014/8/9");
    int x=ps.executeUpdate();
    ps.close();
      
    con.close();//關閉con
    
       
%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>關於' 的過濾問題</h1>
        <%= x %>
    </body>
</html>
